<template lang="html">
  <div class="home-container">
    <el-row class="container">
      <el-col :span="24" class="header">
       <el-col :span="10" class="logo logo-width" v-if="!isCollapse">康师傅芝麻叶手擀面</el-col>
       <el-col :span="10" class="logo logo-collapse-width" v-if="isCollapse">面</el-col>
         <el-col :span="10">
           <div class="tools" @click.prevent="collapseFun">
             <i class="el-icon-menu" ></i>
           </div>
          </el-col>
          <el-col :span="4" class="userinfo">
          <el-dropdown trigger="hover">
            <span class="el-dropdown-link userinfo-inner">消息中心</span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>我的消息</el-dropdown-item>
              <el-dropdown-item>设置</el-dropdown-item>
              <el-dropdown-item divided @click.native="logoutFun">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-col>
       </el-col>
       <el-col :span="24" class="main">
     <aside :class="isCollapse?'menu-collapsed':'menu-expanded'">
        <!--导航菜单-->
     <el-menu default-active="1" theme="dark" class="el-menu-vertical-kkk" @select="handleSelect" :router="true" :unique-opened="true" :collapse-transition="true" @open="handleOpen" @close="handleClose" :collapse="isCollapse">
        <el-menu-item index="1"  route="/overview">
          <i class="el-icon-menu"></i>
          <span slot="title">数据概览</span>
        </el-menu-item>
        <el-submenu index="2">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>微信管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="2-1" route="/wechat/menuManage"><i class="el-icon-location"></i> 菜单管理</el-menu-item>
            <el-menu-item index="2-2" route="/wechat/messageManage"><i class="el-icon-location"></i> 消息管理</el-menu-item>
            <el-menu-item index="2-3" route="/wechat/commentManage"><i class="el-icon-location"></i> 评论管理</el-menu-item>
            <el-menu-item index="2-4" route="/wechat/leaveWordsManage"><i class="el-icon-location"></i> 留言管理</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="3">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>用户管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="1-1" route="/user/userManage">用户管理</el-menu-item>
            <el-menu-item index="1-2" route="/user/userAnalysis">用户分析</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
        <el-submenu index="4">
          <template slot="title">
            <i class="el-icon-location"></i>
            <span>菜品管理</span>
          </template>
          <el-menu-item-group>
            <el-menu-item index="4-1" route="/user/productManage">菜品操作</el-menu-item>
          </el-menu-item-group>
        </el-submenu>
    </el-menu>
  </aside>
     <section class="content-container">
       <div class="grid-content bg-purple-light">
         <el-col :span="24" class="breadcrumb-container">
           <strong class="title">ssss</strong>
           <el-breadcrumb separator="/" class="breadcrumb-inner">
             <el-breadcrumb-item v-for="item in [1,2,3]" :key="item">{{ item }}</el-breadcrumb-item>
           </el-breadcrumb>
         </el-col>
         <el-col :span="24" class="content-wrapper">
           <transition name="fade" mode="out-in">
             <router-view></router-view>
           </transition>
         </el-col>
       </div>
     </section>
   </el-col>
    </el-row>
  </div>
</template>
<script>
export default {
  data () {
    return {
      sysName: 'VueDemo',
      sysUserName: '',
      isCollapse: false
    }
  },
  methods: {
    handleOpen: function (key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose: function (key, keyPath) {
      console.log(key, keyPath)
    },
    handleSelect: function (key, keyPath) {
      console.log(key, keyPath)
    },
    collapseFun: function () {
      this.isCollapse = !this.isCollapse
    },
    showMenu: function (i, status) {
      this.$refs.menuCollapsed.getElementsByClassName('submenu-hook-' + i)[0].style.display = status ? 'block' : 'none'
    },
    logoutFun: function () {
      var _this = this
      this.$confirm('确认退出吗?', '提示', {
      }).then(() => {
        sessionStorage.removeItem('user')
        _this.$router.push('/login')
      }).catch(() => {})
    }
  },
  mounted () {
    var user = sessionStorage.getItem('user')
    if (user) {
      user = JSON.parse(user)
      this.sysUserName = user.username || ''
    }
  }
}
</script>
<style scoped lang="scss">
.container {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 100%;
  .header {
    height: 60px;
    line-height: 60px;
    background: #bbdbfb;
    color: #fff;
    .userinfo {
      text-align: right;
      padding-right: 35px;
      float: right;
      .userinfo-inner {
        cursor: pointer;
        color: #fff;
      }
    }
    .logo {
      height: 60px;
      font-size: 22px;
      padding-left: 20px;
      padding-right: 20px;
      border-color: rgba(238,241,146,0.3);
      border-right-width: 1px;
      border-right-style: solid;
    }
    .logo-width {
        width: 230px;
    }
    .logo-collapse-width {
        width: 65px;
    }
    .tools {
        padding: 0 23px;
        width: 14px;
        height: 60px;
        line-height: 60px;
        cursor: pointer;
    }
  }
  .main {
    display: flex;
    position: absolute;
    top: 60px;
    bottom: 0;
    overflow: hidden;
    aside {
        flex: 0 0 230px;
        width: 230px;
        .el-menu {
            height: 100%;
        }
        .collapsed {
          width: 60px;
          .item {
            position: relative;
          }
          .submenu {
            position: absolute;
            top: 0;
            left: 60px;
            z-index: 99999;
            height: auto;
            display: none;
          }
        }
    }
    .menu-collapsed {
        flex: 0 0 60px;
        width: 60px;
    }
    .menu-expanded {
        flex: 0 0 230px;
        width: 230px;
    }
    .content-container {
      flex: 1;
      overflow-y: scroll;
      padding: 20px;
      .breadcrumb-container {
        .title {
          width: 200px;
          float: left;
          color: #475669;
        }
        .breadcrumb-inner {
          float: right;
        }
      }
      .content-wrapper {
        box-sizing: border-box;
      }
    }
  }
}
</style>
